package com.mcptt.db;

import com.mcptt.db.model.UserInfo;

import android.content.ContentResolver;
import android.net.Uri;

public class DbConst {



	public static final String AUTHORITY = "com.mcptt.db";
	public static final String BASE_DIR_TYPE = "vnd.android.cursor.dir/vnd.csipsimple";
	public static final String BASE_ITEM_TYPE = "vnd.android.cursor.item/vnd.csipsimple";

	public static final String _ID = "_id";




	//鍘嗗彶浼氳瘽琛�
	public static final String History_Table = "history";
	public static final String Test_Table = "test";

	//    public static final String COL_ReceiverUId  = "receiverUId";
	public static final String COL_ReceiverNum  = "receiverNum";
	//    public static final String COL_lastSenderUId   = "lastSenderUId";
	public static final String COL_lastSenderType   = "lastSenderType";
	public static final String COL_lastSenderNum   = "lastSenderNum";
	public static final String COL_lastSenderName   = "lastSenderName";
	public static final String COL_LastMsgType      = "lastMsgType";
	public static final String COL_LastMsgContent      = "lastMsgContent";
	public static final String COL_LastMsgDate      = "lastMsgDate";
	public static final String COL_UnreadCount        = "unreadCount";
	public static final String COL_Affiliation        = "affiliation";

	public static final String HISTORY_TYPE = BASE_DIR_TYPE + ".sessionList";
	/**
	 * Item type for history provider.
	 */
	public static final String HISTORY_ITEM_TYPE = BASE_ITEM_TYPE + ".sessionList";
	/**
	 * Uri for history content provider.
	 */
	public static final Uri HISTORY_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ History_Table);
	/**
	 * Base uri for a specific history. Should be appended with id of the history
	 */
	public static final Uri HISTORY_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ History_Table+ "/");

	public static final Uri HISTORY_TEST = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Test_Table+ "/");

	//鍘嗗彶淇℃伅琛�

	public static final String Session_Table = "session";

	//  public static final String COL_ReceiverUId  = "receiverUId";
	//    	public static final String COL_ReceiverNum  = "receiverNum";
	//    public static final String COL_SenderUId = "senderUId";
	public static final String COL_SenderId = "senderId";
	public static final String COL_Content = "content";
	public static final String COL_Date = "date";
	public static final String COL_MsgType = "msgType";
	public static final String COL_Direction  = "direction";
	public static final String COL_Len  = "len";
	public static final String COL_Status  = "status";

	public static final String SESSION_TYPE = BASE_DIR_TYPE + ".session";
	/**
	 * Item type for call logs provider.
	 */
	public static final String SESSION_ITEM_TYPE = BASE_ITEM_TYPE + ".session";
	/**
	 * Uri for call log content provider.
	 */
	public static final Uri SESSION_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Session_Table);
	/**
	 * Base uri for a specific call log. Should be appended with id of the call log.
	 */
	public static final Uri SESSION_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Session_Table+ "/");


	public static final String Map_Point_Table = "map_point";
	public static final String COL_IsSendRequest = "isSendRequest";
	public static final String COL_Lattitude = "lattitude";
	public static final String COL_Longitude = "longitude";
	public static final String COL_Altitude = "altitude";
	public static final String COL_Time = "time";
	/*public static final String COL_Last_Time = "last_time";*/
	public static final String COL_Loc_Info = "location_info";
	public static final String COL_Loc_Type = "location_type";
	public static final String Location_Track_Table = "location_track";
	public static final String COL_Valid = "location_valid";

	public static final String MAP_POINT_TYPE = BASE_DIR_TYPE + ".map_point";
	/**
	 * Item type for call logs provider.
	 */
	public static final String MAP_POINT_ITEM_TYPE = BASE_ITEM_TYPE + ".map_point";
	/**
	 * Uri for call log content provider.
	 */
	public static final Uri MAP_POINT_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Map_Point_Table);
	/**
	 * Base uri for a specific call log. Should be appended with id of the call log.
	 */
	public static final Uri MAP_POINTID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Map_Point_Table+ "/");

	
//	public static final Uri LOCATION_TRACK_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
//			+ AUTHORITY + "/"
//			+ Location_Track_Table);
	
	public static final Uri LOCATION_TRACK_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Location_Track_Table + "/");
	
	public static final String LOCATION_TRACK_TYPE = BASE_DIR_TYPE + ".location_track";
	
	public static final String LOCATION_TRACK_ITEM_TYPE = BASE_DIR_TYPE + ".location_track";



	//閫氳褰曡〃
	public static final String AddressList_Table = "address";
	public static final String AddressList_View = "address_view";
	public static final String COL_Id = "id";
	//	public static final String COL_UID = "uId";
	public static final String COL_Type = "type"; 
	public static final String COL_Name = "name";
//	public static final String COL_McpttId = "mcpttId";
//	public static final String COL_McvideoId = "mcvideoId";
//	public static final String COL_McdataId = "mcdataId";
	public static final String COL_Attr = "attr";
//	public static final String COL_state = "state";
	public static final String COL_GroupId = "groupId";
	//	public static final String COL_ImageId = "imageId";
	



	public static final String ADDRESS_TYPE = BASE_DIR_TYPE + ".address";
	/**
	 * Item type for address provider.
	 */
	public static final String ADDRESS_ITEM_TYPE = BASE_ITEM_TYPE + ".address";
	/**
	 * Uri for address content provider.
	 */
	public static final Uri ADDRESS_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ AddressList_Table);
	/**
	 * Base uri for a specific address. Should be appended with id of the address
	 */
	public static final Uri ADDRESS_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ AddressList_Table+ "/");
	
	
	
	
	
	public static final String Camera_Table = "camera";
	public static final String COL_Ip = "ip";
	public static final String COL_UserName = "userName";
	public static final String COL_Pwd = "pwd";
	



	public static final String CAMERA_TYPE = BASE_DIR_TYPE + ".camera";
	/**
	 * Item type for address provider.
	 */
	public static final String CAMERA_ITEM_TYPE = BASE_ITEM_TYPE + ".camera";
	/**
	 * Uri for address content provider.
	 */
	public static final Uri CAMERA_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Camera_Table);
	/**
	 * Base uri for a specific address. Should be appended with id of the address
	 */
	public static final Uri CAMERA_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Camera_Table+ "/");
	
	
	
	
	
	public static final String GroupAddressList_Table = "group_address";
	public static final String COL_PGroupId = "p_groupId";
	public static final String COL_GCallTimer = "gcall_timer";
//	public static final String COL_McId = "mcId";
//	//	public static final String COL_UID = "uId";
//	public static final String COL_UserType = "userType"; 
//	public static final String COL_Name = "name";
//	public static final String COL_GroupId = "groupId";
//	public static final String COL_McvideoId = "mcvideoId";
//	public static final String COL_McdataId = "mcdataId";
//	public static final String COL_Attr = "attr";
//	public static final String COL_Count = "count";
	
	public static final String GROUP_ADDRESS_TYPE = BASE_DIR_TYPE + ".group_address";
	/**
	 * Item type for address provider.
	 */
	public static final String GROUP_ADDRESS_ITEM_TYPE = BASE_ITEM_TYPE + ".group_address";
	/**
	 * Uri for address content provider.
	 */
	public static final Uri GROUP_ADDRESS_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ GroupAddressList_Table);
	/**
	 * Base uri for a specific address. Should be appended with id of the address
	 */
	public static final Uri GROUP_ADDRESS_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ GroupAddressList_Table+ "/");

	
	public static final String LoginState_Table = "login";
	public static final String COL_State  = "state";
	
	public static final String LOGIN_TYPE = BASE_DIR_TYPE + ".login";
	
	public static final String LOGIN_ITEM_TYPE = BASE_ITEM_TYPE + ".login";
	
	public static final Uri LOGIN_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ LoginState_Table);
	
	public static final Uri LOGIN_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ LoginState_Table+ "/");

	//閫氳褰曡〃
	public static final String Config_Table = "config";
	public static final String COL_FileName = "fileName";
	public static final String COL_ETag = "eTag"; 
	public static final String COL_ConfigContent = "content";

	public static final String CONFIG_TYPE = BASE_DIR_TYPE + ".config";
	/**
	 * Item type for address provider.
	 */
	public static final String CONFIG_ITEM_TYPE = BASE_ITEM_TYPE + ".config";
	/**
	 * Uri for address content provider.
	 */
	public static final Uri CONFIG_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Config_Table);
	/**
	 * Base uri for a specific address. Should be appended with id of the address
	 */
	public static final Uri CONFIG_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Config_Table+ "/");


	//閫氳褰曡〃
	public static final String Group_Config_Table = "group_config";
	public static final String COL_GroupName = "groupName";
	//		public static final String COL_ETag = "eTag"; 
	//		public static final String COL_ConfigContent = "content";

	public static final String GROUP_CONFIG_TYPE = BASE_DIR_TYPE + ".group_config";
	/**
	 * Item type for address provider.
	 */
	public static final String GROUP_CONFIG_ITEM_TYPE = BASE_ITEM_TYPE + ".group_config";
	/**
	 * Uri for address content provider.
	 */
	public static final Uri GROUP_CONFIG_URI = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Group_Config_Table);
	/**
	 * Base uri for a specific address. Should be appended with id of the address
	 */
	public static final Uri GROUP_CONFIG_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ Group_Config_Table+ "/");



	//缇ょ粍鎴愬憳琛�
	public static final String MEMBER_TABLE = "member";

	public static final String COL_MEMBER_GROUP_NUM      = "gnum";
	//    public static final String COL_MEMBER_PUID     = "puid";
	public static final String COL_MEMBER_NUM      = "NUM";
	public static final String COL_MEMBER_NAME     = "name";
	public static final String COL_MEMBER_PRIORITY     = "priority";
	public static final String COL_MEMBER_STATUS     = "status";

	public static final String MEMBER_TYPE = BASE_DIR_TYPE + ".member";
	/**
	 * Item type for member provider.
	 */
	public static final String MEMBER_ITEM_TYPE = BASE_ITEM_TYPE + ".member";
	/**
	 * Uri for member content provider.
	 */
	public static final Uri MEMBER_URI  = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ MEMBER_TABLE);
	/**
	 * Base uri for a specific member. Should be appended with id of the member
	 */
	public static final Uri MEMBER_ID_URI_BASE = Uri.parse(ContentResolver.SCHEME_CONTENT + "://"
			+ AUTHORITY + "/"
			+ MEMBER_TABLE+ "/");


	protected final static String QUERY_HIRSTORY =  "SELECT distinct  * FROM  "
			+ History_Table 
			+" left outer join " + AddressList_View 
			+ " on " + COL_ReceiverNum 
			+ " = " + COL_Id
			+" order by " + COL_Type + " asc"
			+" , " + COL_LastMsgDate + " desc";

	protected final static String QUERY_SESSION =  "SELECT distinct  * FROM  "
			+ Session_Table
			+" left outer join " + AddressList_View 
			+ " on " + COL_SenderId 
			+ " = " + COL_Id 
			+ " where " + COL_ReceiverNum + " = ";
	
	protected final static String QUERY_MAPPOINT =  "SELECT distinct  * FROM  "
			+ Map_Point_Table
			+" left outer join " + AddressList_Table 
			+ " on " + COL_SenderId 
			+ " = " + COL_Id;
	
	protected final static String QUERY_LOGINSTATE = "SELECT distinct  * FROM "
			+ AddressList_Table
			//+ " left join " + LoginState_Table
			//+ " on " + COL_SenderId
			//+ " = " + COL_Id
			+ " where ";
	protected final static String QUERY_LOGINSTATE_ORDER = " order by " + COL_State + " DESC, " + COL_Type + " ASC";// + COL_Name + " ASC";

	protected static String getQuerySessionSqlStr(String receiverUId)
	{
		String sqlStr = DbConst.QUERY_SESSION + "'" + receiverUId + "'";
		return sqlStr;
	}
}
